﻿using MediatR;
using WMS.API.Application.Command.DeliveryOrderManagement.DeliveryOrder;
using WMS.Domain.Entities.DeliveryOrderManagement;
using WMS.ErrorCode;
using WMS.Interfactructure.Interfaces;

namespace WMS.API.Application.CommandHandlers.DeliveryOrderManagement.DeliveryOrder
{
    public class FTPendingFreightCommandHandler : IRequestHandler<FTPendingFreightCommand, APIResult<List<PendingFreightModel>>>
    {
        private readonly IBaseRepository<PendingFreightModel> _pendingrepository;

        public FTPendingFreightCommandHandler(IBaseRepository<PendingFreightModel> pendingrepository)
        {
            this._pendingrepository = pendingrepository;
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public  Task<APIResult<List<PendingFreightModel>>> Handle(FTPendingFreightCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<PendingFreightModel>> result=new APIResult<List<PendingFreightModel>>("反填成功待发货订单");
            result.Message = "反填成功待发货订单";
            result.Code=ResultCode.Success;

            var list = _pendingrepository.GetAll(x=>x.Id==request.Id).ToList();
            result.Data = list;
            return Task.FromResult(result);
        }
    }
}
